<template>
  <div>
    <h2>你好我是home组件</h2>
    <button @click="addNum">+</button>
    <button @click="reduceNum">-</button>
    {{ $store.state.num }}
    <button @click="initNum">点击发送异步请求 赋值  num</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
    }
  },
  methods: {
    addNum () {
      this.$store.commit('add_num', 10)
    },
    reduceNum () {
      this.$store.commit('reduce_num', 5)
    },
    initNum () {
      // 触发action
      this.$store.dispatch('set_num_async', 666)
    }
  },
  mounted () {
    console.log(this)
  }
}
</script>

<style lang="scss" scoped>

</style>
